package com.lzy.web.facade.mq;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ellengou
 * Date: 2017-12-13
 * Time: PM 1:55
 */
@Service
public class RabbitmqReturnCallBackListener implements RabbitTemplate.ReturnCallback {

    private static Logger logger = LoggerFactory.getLogger(RabbitmqReturnCallBackListener.class);

    @Override
    public void returnedMessage(Message message, int replyCode, String replyText, String exchange, String routingKey) {
        try {
            logger.info("return--message:" + new String(message.getBody()) + ",replyCode:" + replyCode + ",replyText:" + replyText + ",exchange:" + exchange + ",routingKey:" + routingKey);
            //做相应的业务操作
        } catch (Exception e) {
            logger.error("message return callback exception：" + e);

        }
    }
}